<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if ($CURUSER < UC_MODERATOR && $CURUSER['id'] != $betsadmin)
	stderr("错误", "权限不足");
$id = isset($_GET['id']) && is_valid_id($_GET['id']) ? $_GET['id'] : 0;
$res = sql_query("SELECT * FROM bets WHERE gameid =" . sqlesc($id) . "") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0) {
	stderr("错误", "请点击第二删除选项");
} else {
	sql_query("DELETE FROM betgames WHERE id =" . sqlesc($id) . "") or sqlerr(__FILE__, __LINE__);
	sql_query("DELETE FROM betoptions WHERE gameid =" . sqlesc($id) . "") or sqlerr(__FILE__, __LINE__);
	sql_query("DELETE FROM bets WHERE gameid =" . sqlesc($id) . "") or sqlerr(__FILE__, __LINE__);
	header("location: bet_admin.php");
}